<template>
    <Layout title="个人中心" :header="false">
        <div class="my-top">
            <van-image round v-if="!isLogin">
                <template v-slot:loading>
                    <van-icon name="manager" />
                </template>
            </van-image>
            <van-image v-else :src="me.avatar" round></van-image>
            <p v-if="!isLogin">
                <router-link to="/login?back=my" tag="span">登录</router-link>
                <span> / </span>
                <router-link to="/reg" tag="span">注册</router-link>
            </p>
            <p v-else>{{ me.nick_name ? me.nick_name : "---" }}</p>
        </div>
        <div class="my-order fixed-border-b1">
            <van-cell title="全部订单" is-link to="/order">
                <template #icon>
                    <img src="../../assets/images/my-order.svg" alt="" />
                </template>
            </van-cell>
            <van-row>
                <van-col span="8">
                    <img src="../../assets/images/my-wait-pay.svg" alt="" />
                    <p>待付款</p>
                </van-col>
                <van-col span="8">
                    <img
                        src="../../assets/images/my-wait-delivery.svg"
                        alt=""
                    />
                    <p>待发货</p>
                </van-col>
                <van-col span="8">
                    <img src="../../assets/images/my-wait-comment.svg" alt="" />
                    <p>待评价</p>
                </van-col>
            </van-row>
        </div>
        <div class="my-other fixed-border-b1 fixed-border-t1">
            <van-cell title="我的消息" is-link to="/message">
                <template #icon>
                    <img src="../../assets/images/my-msg.svg" alt="" />
                </template>
            </van-cell>
            <van-cell title="我的收藏" is-link to="/collection">
                <template #icon>
                    <img src="../../assets/images/my-collection.svg" alt="" />
                </template>
            </van-cell>
            <van-cell
                title="我的地址"
                is-link
                :value="isLogin ? '广州市天河区车陂黄洲工业园' : ''"
                to="/address"
            >
                <template #icon>
                    <img src="../../assets/images/my-address.svg" alt="" />
                </template>
            </van-cell>
            <van-cell title="我的优惠" is-link value="微信支付" to="/discount">
                <template #icon>
                    <img src="../../assets/images/my-discount.svg" alt="" />
                </template>
            </van-cell>
        </div>
        <div class="my-scan fixed-border-b1 fixed-border-t1">
            <van-cell title="门店扫码" is-link value="扫码提货" to="/scan">
                <template #icon>
                    <img src="../../assets/images/my-scan.png" alt="" />
                </template>
            </van-cell>
        </div>
        <div class="my-btn" v-if="isLogin">
            <van-button @click="onLogout" type="danger" round block
                >退出登录</van-button
            >
        </div>
    </Layout>
</template>

<script src="./js/index.js"></script>
<style lang="less" scoped src="./less/index.less"></style>